<template>
	<wd-navbar fixed placeholder safeAreaInsetTop title="易行邮"></wd-navbar>

	<page-wraper :safeAreaInsetBottom="false">
		<!-- <view class="content-body">
			<wd-card v-for="(item, index) in notices" :key="index" :title="item.title">
				<view class="notice-content">
					<view v-html="fixContent(item.content)" @click="handleNotice(item.id)" v-if="!item.isVideo"></view>
					<video :src="item.src" class="video" :autoplay="false" v-else></video>
				</view>
			</wd-card>
		</view> -->
		<image src="https://www.ytad-pep.com/index-bg.png" style="width: 100%;"></image>
		
		<view class="container">
		  <view class="header">
		    <text class="title">我的服务</text>
		    <text class="badge">官方服务更安心</text>
		  </view>
		
		  <view class="grid-container">
		    <view class="grid-item" bindtap="onServiceGuide">
		      <text>服务指引</text>
		    </view>
		    <view class="grid-item" bindtap="onParcelRequest">
		      <text>我要寄件</text>
		    </view>
		    <view class="grid-item" bindtap="onPromotion">
		      <text>优惠活动</text>
		    </view>
		    <view class="grid-item" bindtap="onShippingCalculator">
		      <text>运费计算</text>
		    </view>
		    <view class="grid-item" bindtap="onProductAdvantage">
		      <text>产品优势</text>
		    </view>
		    <view class="grid-item" bindtap="onFAQ">
		      <text>常见问题</text>
		    </view>
		    <view class="grid-item" bindtap="onProhibitedItems">
		      <text>禁寄信息</text>
		    </view>
		    <view class="grid-item" bindtap="onOrderDemo">
		      <text>下单演示</text>
		    </view>
		  </view>
		</view>

		<page-nav-bar></page-nav-bar>
	</page-wraper>
</template>

<script lang="ts" setup>
	import { ref } from 'vue'
	import { onLoad } from '@dcloudio/uni-app'

	const notices = ref<any>([])

	function fixContent(content : String) {
		return content.replace(/<img/gi, '<img style="max-width:100%;height:auto;margin:0 auto;display:block"')
	}

	onLoad((query) => {
		/*
		uni.$http.get('../../notice/list?page=1&limit=10&sort=created&order=desc').then(res => {
			if (res.data.code === 0) {
				notices.value = res.data.data
				
				for (var i = 0; i < notices.value.length; i++) {
					if (notices.value[i].content.indexOf('<video') != -1) {
						var m = /src="([^"]+)"/.exec(notices.value[i].content);
						
						notices.value[i].isVideo = true;
						notices.value[i].src = m[1];
					} else {
						notices.value[i].isVideo = false;
					}
				}
			}
		});*/
	})

	function handleNotice(id : number) {
		uni.navigateTo({ url: `/pages/notice/Index?id=${id}` })
	}
</script>

<style lang="scss" scoped>
	:deep(.page-wraper) {
		background: #f6f6f6;
	}

	.content-body {
		margin-top: 10rpx;
	}

	.notice-content {
		height: 150px;
		overflow: hidden;
	}
	
	.video {
		width: 100%;
		height: 150px;
	}
	
	.container {
	  padding: 20rpx;
	  background-color: #4BA3E3;
	  min-height: 100vh;
	}
	
	.header {
	  padding: 20rpx 0;
	  margin-bottom: 30rpx;
	}
	
	.title {
	  font-size: 36rpx;
	  font-weight: bold;
	  color: #000;
	}
	
	.badge {
	  font-size: 24rpx;
	  color: #666;
	  background-color: #f5f5f5;
	  padding: 4rpx 12rpx;
	  border-radius: 8rpx;
	  margin-left: 20rpx;
	}
	
	.grid-container {
	  display: grid;
	  grid-template-columns: repeat(2, 1fr);
	  gap: 20rpx;
	  padding: 0 10rpx;
	}
	
	.grid-item {
	  background-color: rgba(255, 255, 255, 0.9);
	  height: 180rpx;
	  border-radius: 16rpx;
	  display: flex;
	  align-items: center;
	  justify-content: center;
	  font-size: 32rpx;
	  color: #333;
	  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
	}
	
	.grid-item:active {
	  background-color: rgba(255, 255, 255, 0.7);
	}
	
	.customer-service {
	  position: fixed;
	  bottom: 40rpx;
	  right: 40rpx;
	}
	
	.service-icon {
	  width: 100rpx;
	  height: 100rpx;
	  border-radius: 50%;
	  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.15);
	}
</style>